73.1.1 配置logback只输出到文件

如果想禁用控制台日志记录,只将输出写入文件中,你需要一个只导入file-appender.xml而不是console-appender.xml的自定义logback-spring.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}"/>
    <include resource="org/springframework/boot/logging/logback/file-appender.xml" />
    <root level="INFO">
        <appender-ref ref="FILE" />
    </root>
</configuration>

你还需要将logging.file添加到application.properties

logging.file=myapplication.log